package com.ygqh.baby.service;

import com.ygqh.baby.ao.*;
import com.ygqh.baby.model.UserBalanceDetailModel;
import com.ygqh.baby.model.YgUserRecommendModel;
import com.ygqh.baby.po.YgUserBalanceDetail;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface YgUserBalanceDetailService {

	List<YgUserBalanceDetail> find();

	int findCount();

	YgUserBalanceDetail findById(Long id);

	int save(YgUserBalanceDetail ygUserBalanceDetail);

	int update(YgUserBalanceDetail ygUserBalanceDetail);

	int saveOrUpdate(YgUserBalanceDetail ygUserBalanceDetail);

	ResultSet<YgUserBalanceDetail> search(QueryInfo queryInfo, String remark, String username, Date startDate, Date endDate);

	ResultSet<YgUserBalanceDetail> findByUserIdPage(QueryInfo queryInfo, Long userId);

	Map<String, Object> getOrderPriceBySourceCode(List<String> sourceCodeList);

	YgUserBalanceDetail findRedPacketRechargeByOrderId(Long orderId);

	List<YgUserBalanceDetail> findDetailByOperationType(Long userId, OperationType operationType, String relationId);

	List<YgUserBalanceDetail> findDetailByTime(BalanceType balance, Date startTime, Date endTime);

	int addBalanceDetail(Long userId, BigDecimal money, BalanceType balanceType, OperationType operationType, String remark);

	/**
	 * 获取每有返利的预收入(接口逻辑不完善，) TODO
	 *
	 * @param orderIds 入参
	 * @return List<YgUserBalanceDetail> 返回类型
	 * @throws @date 2017年11月2日 上午10:47:45
	 * @Title: findNoBalanceInComeListByOrderIds
	 * @author （guohao）
	 * @version V1.0
	 */
	List<YgUserBalanceDetail> findNoBalanceInComeListByOrderIds(Long[] orderIds);

	int countByOrderId(String orderId, BalanceType balanceType, RebateType rebateType);

	List<YgUserBalanceDetail> findDetailByOrderDetail(BalanceType balanceType, RebateType rebateType,
													  Long userId, String orderId, Long orderDetailId);

	/**
	 * @param balanceType
	 * @param rebateType
	 * @param userId
	 * @param orderType     'order' 'return'
	 * @param orderDetailId
	 * @return
	 */
	List<YgUserBalanceDetail> findByOrderDetailId(BalanceType balanceType, RebateType rebateType,
												  Long userId, String orderType, Long orderDetailId);

	Boolean exitBalanceDetailByOrderId(BalanceType balanceType, RebateType rebateType, String orderId, Long userId);

	List<YgUserBalanceDetail> selectBalanceDetailByOrderId(BalanceType balanceType, RebateType rebateType,
														   Long userId, List<String> orderIdList, String platformNo);

	List<YgUserBalanceDetail> findBalanceDetailsGroupByOrder(QueryInfo queryInfo, Long userId, BalanceType balanceType);

	List<YgUserBalanceDetail> findBalanceReturnDetailByOrderId(BalanceType balanceType, RebateType rebateType, Long orderId);

	/**
	 * 将原用户的返利明细转移到目标用户下
	 *
	 * @param sourceUserId
	 * @param targetUserId
	 * @return int    返回类型
	 * @throws
	 * @Title: transferBalanceDetail
	 * @author （guohao）
	 * @date 2018年5月11日 上午10:54:29
	 * @version V1.0
	 */
	int transferBalanceDetail(Long sourceUserId, Long targetUserId);

	int updateIsGived(Boolean isGived, List<Long> idlList);

	int updateIsGivedByOrderIdList(Boolean isGived, List<String> orderIdList);

	/**
	 * 我的返利信息
	 *
	 * @param userId     用户id
	 * @param platformNo 平台NO
	 * @return 返利信息
	 */
	Map<String, Object> findMyRebate(Long userId, String platformNo);

	/**
	 * 统计粉丝贡献佣金
	 *
	 * @param userId              用户id
	 * @param recommendUserIdList 粉丝id集
	 * @param platformNo          平台NO
	 * @return
	 */
	List<YgUserRecommendModel> statisticsRecommendPrice(@Param("userId") Long userId,
														@Param("userIdList") List<Long> recommendUserIdList,
														@Param("platformNo") String platformNo);

	/**
	 * 收益明细
	 *
	 * @param queryInfo   分页
	 * @param userId      用户id
	 * @param limitTime   限制时间
	 * @param platformNo  平台NO
	 * @param balanceType 收益类型
	 * @return
	 */
	List<UserBalanceDetailModel> findDetailList(QueryInfo queryInfo, Long userId, Date limitTime, String platformNo,
												BalanceType balanceType);
}
